package com.gocoolmall.order.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 订单确认页需要用的数据
 */
public class OrderConfirmVO {

    //收货地址，ums_member_receive_address
    @Getter @Setter
    List<MemberAddressVO> address;

    //所以选中的购物项
    @Getter @Setter
    List<OrderItemVo> item;

    //发票信息

     //防重令牌
    @Getter @Setter
    String orderToken;

    //总数量
    Integer count;
    public Integer getCount(){
        Integer i = 0;
        if (item != null){
            for(OrderItemVo item:item){
                i+=item.getCount();
            }
        }
        return  i;
    }

    //优惠卷的信息
    @Getter @Setter
    Integer integeration;

    //是否有库存
    @Getter @Setter
    Map<Long,Boolean> stocks;

    BigDecimal total;//订单总额

    public BigDecimal getTotal() {
        BigDecimal sum = new BigDecimal("0");
        if (item != null){
            for(OrderItemVo items:item){
                BigDecimal multiply = items.getPrice().multiply(new BigDecimal(items.getCount().toString()));
                sum = sum.add(multiply);
            }
        }
        return sum;
    }

    BigDecimal payPrice;//应付价格

    public BigDecimal getPayPrice() {
        return getTotal();
    }
}
